<?php
require '../conn.php';
require 'config.php';
require '../inc/function.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../css/admin.css" type="text/css" />
<script type="text/javascript" src="inc/function.js"></script>
</head>
<body>
<?php
switch($act){
case 'delete':
	$imagj_original=RsField_Array('select j_image from '.$language.'_journal where j_id='.$id);
	mysql_query('delete from '.$language.'_journal where j_id='.$id);
	DeleteFile('../'.$imagj_original[0]);
	Msg('','Referer');
	break;
case 'deletes':
	if (count($_POST['checkbox'])>0){
		$id_arr=implode(',',$_POST['checkbox']);
		$query=mysql_query("select j_id,j_image from ".$language."_journal where j_id in ($id_arr)");
		if (mysql_num_rows($query)>0){
		while($row=mysql_fetch_array($query)){
			mysql_query('delete from '.$language.'_journal where j_id='.$row['j_id']);
			DeleteFile('../'.$row['j_image']);
		}
		}
	}
	Msg('删除数据成功！','Referer');
	break;
case 'index':
	mysql_query('update '.$language.'_journal set j_index=1 where j_id='.$id);
	Msg('','Referer');
	break;
case 'unindex':
	mysql_query('update '.$language.'_journal set j_index=0 where j_id='.$id);
	Msg('','Referer');
	break;
}
?>
<div id="container">
	<input type="text" id="search_key" class="search_input" size="30" value="<?php echo  $search_key ?>" />
	<input type="button" name="button" class="search_button" value="搜 索" onclick="location.href='?search_key='+$('search_key').value" />
	<?php
	$str='';
	$str.='&nbsp;&nbsp;';
	$str.='分类查看：<select id="j_class" class="input_selects" onchange="ChangeClass(this.value);"><option value="">请选择</option>';
	$query=mysql_query('select * from '.$language.'_journal_class order by j_order,j_id');
	if (mysql_num_rows($query)>0){
	while($row=mysql_fetch_array($query)){
		$str.='<option value="'.$row['j_id'].'">'.$row['j_name'].'</option>';
	}
	}
	$str.='</select>';
	if ($meter!=''){
		$str.='<script type="text/javascript">$("j_class").value="'.$meter.'";</script>';
		$sqls=' and j_class='.$meter;
	}
	$str.='&nbsp;&nbsp;';
	if ($indexs==1){
		$str.='<a href="journal.php" style="color:#ff0000; font-weight:bold;">首页显示</a>';
		$sqls=' and j_index=1';
	}
	else {
		$str.='<a href="journal.php?indexs=1">首页显示</a>';
	}
	if ($search_key!='') $sqls=" and j_name like '%{$search_key}%'";
	echo $str;
	?>
	<div class="view" style="margin-top:5px;">
		<h1>外贸杂志<a href="javascript:location.reload();">刷新</a></h1>
		<form name="form1" id="form1" method="post" action="?act=deletes&<?php echo $urls ?>">
	    <table width="100%" border="0" cellpadding="0" cellspacing="0">
        	<tr class="v_title">
            	<td width="8%">ID号</td>
				<td width="15%">杂志分类</td>
				<td width="15%">图片预览</td>
				<td width="30%">杂志名称</td>
				<td width="10%">首页显示</td>
				<td width="10%">展会排序</td>
				<td width="12%">操作</td>
        	</tr>
			<?php
			$str='';
			$pagj_size=10;
			$pagj_sql='select j_id,j_class,j_order,j_index,j_name,j_image from '.$language.'_journal where 1=1'.$sqls;
			$sqls_order=' order by j_id desc';
			if ($meter!='' || $meter2!='' || $meter3!='') $sqls_order=' order by j_order,j_id';
			$pagj_sql.=$sqls_order;
			$pagj_count=GetPageCount($pagj_size,$pagj_sql);
			if ($page>$pagj_count) $page=$pagj_count;
			$pagj_number=($page-1)*$pagj_size;
			$query=mysql_query($pagj_sql." limit $pagj_number,$pagj_size",$conn);
			if (mysql_num_rows($query)>0){
			while($row=mysql_fetch_array($query)){
				$str.='<tr onmouseover="this.className=\'view_trover\';" onmouseout="this.className=\'view_trout\';">';
				$str.='<td><input type="checkbox" name="checkbox[]" value="'.$row['j_id'].'" align="absmiddle" />&nbsp;'.$row['j_id'].'</td>';
				$str.='<td>'.RsField('select j_name from '.$language.'_journal_class where j_id='.$row['j_class']).'</td>';
				$str.='<td style="line-height:normal; font-size:0px;"><a href="../'.$row['j_image'].'" target="_blank"><img src="../'.$row['j_image'].'" height="40" style="margin:5px auto;" /></a></td>';
				$str.='<td><a href="../journal_detail.php?cid='.$row['j_class'].'&id='.$row['j_id'].'" target="_blank">'.$row['j_name'].'</a></td>';
				$str.='<td>';if($row['j_index']==1){$str.='<span style="color:#ff0000;">是</span> <a href="?act=unindex&id='.$row['j_id'].'">(取消)</a>';}else{$str.='否 <a href="?act=index&id='.$row['j_id'].'">(显示)</a>';}$str.='</td>';
				if ($meter==''){
					$str.='<td>'.$row['j_order'].'</td>';
				}
				else {
					$str.='<td><div class="inputorder" id="inputorder_'.$row['j_id'].'" contenteditable="true" onblur="Order(\'journal\','.$row['j_id'].')">'.$row['j_order'].'</div></td>';
				}
				$str.='<td><a href="journal_modify.php?'.$urls.'&id='.$row['j_id'].'">修改</a> | <a href="?act=delete&id='.$row['j_id'].'" onclick="return ConfirmDel();">删除</a></td>';
				$str.='</tr>';
			}
			}
			else {
				$pagj_show=false;
			}
			echo $str;
			?>
		</table>
		</form>
		<?php if($pagj_show) echo ShowPage($page,$pagj_size,$pagj_sql); ?>
	</div>
</div>
</body>
</html>